/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.stuffrepos.bricknetcenter.util.gui;

import javax.swing.AbstractListModel;
import net.stuffrepos.bricknetcenter.database.LazyResultSet;

/**
 *
 * @author Eduardo H. Bogoni <eduardobogoni@gmail.com>
 */
public class LazyResultSetListModel extends AbstractListModel {

    private final LazyResultSet lazyResultSet;

    public LazyResultSetListModel(LazyResultSet lazyResultSet) {
        assert lazyResultSet != null;
        this.lazyResultSet = lazyResultSet;
    }

    @Override
    public int getSize() {
        try {
            return lazyResultSet.getTotalSize();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    @Override
    public Object getElementAt(int index) {
        try {
            return lazyResultSet.getElementAt(index);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
}
